import axios from "../utils/request.js"
import base from "./base.js"


const api = {
    /**
     * 登录
     */
    login(params) {
        return axios.post(base.baseUrl + base.login, params)
    },
    test_response(params) {
        return axios.get(base.baseUrl + base.test_response, params)
    },
    get_menu(params) {
        return axios.get(base.baseUrl + base.get_menu, params)
    },
    get_menu_list(params) {
        return axios.get(base.baseUrl + base.get_menu_list, params)
    },
    get_user_list(params) {
        return axios.get(base.baseUrl + base.get_users, params)
    },
    add_user(params) {
        return axios.post(base.baseUrl + base.get_users, params)
    },
    get_user_by_id(id) {
        return axios.get(base.baseUrl + base.get_user_by_id + id + '/')
    },
    edit_user(id, params) {
        return axios.put(base.baseUrl + base.get_user_by_id + id + '/', params)
    },
    delete_user(id) {
        return axios.delete(base.baseUrl + base.get_user_by_id + id + '/')
    },
    reset_user(id) {
        return axios.get(base.baseUrl + base.reset_user + id + '/')
    },
    get_roles(params) {
        return axios.get(base.baseUrl + base.get_roles, params)
    },
    del_role_menu(rid, mid) {
        return axios.get(base.baseUrl + base.del_role + rid + '/' + mid + '/')
    },
    set_menu(rid,params) {
        return axios.post(base.baseUrl + base.set_menu + rid + '/', params)
    },
    get_categories(level){
        return axios.get(base.baseUrl + base.get_category + "?level=" + level)
    },
    add_category(params) {
        return axios.post(base.baseUrl + base.add_category, params)
    },
    get_attr_by_category(cid, _type){
        return axios.get(base.baseUrl + base.get_attr_by_category + "?cid=" + cid + "&_type=" + _type)
    },
    add_attribute(params) {
        return axios.post(base.baseUrl + base.add_attr, params)
    },
    add_attr_value(id, params) {
        return axios.put(base.baseUrl + base.add_attr_value + id + '/', params)
    }
}


export default api
